<template>
	<view style="padding-top: 100rpx;">
		<view class="mdx-center-xs">
			<view class="login-top">
				<image src="../../static/login/logo.png"></image>
			</view>
		</view>
		<view class="mdx-center-xs greet">
			<view>亲爱的，{{userInfo.enterprisename||''}}-{{name||''}} </view>
			<view>您好！</view>
		</view>
		<view class="mdx-center-xs" style="text-align: center;">
			<image src="../../static/login/ling.png" class="greet_img"></image>
		</view>
		<view class="hui99" style="text-align: center;width: 60%;margin: 0 auto;">
			您当前正在完成{{gwName||' '}}岗位的系统学习
			祝您学习愉快
		</view>
		<view class="mdx-center-xs" style="margin-top: 100rpx;">
			<u-button v-if="!textOpen" :custom-style="customStyle" :hair-line='false' @click="studyTest">开启学前测试
			</u-button>
			<!-- <button @click="study">开启学习之旅</button> -->
			<u-button :custom-style="customStyle" :hair-line='false' @click="study">开启学习之旅</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: '',
				gwName: '',
				customStyle: {
					marginTop: '30rpx', // 注意驼峰命名，并且值必须用引号包括，因为这是对象
					color: '#fff',
					background: '#00A29A'
				},
				textOpen: false,
				postId: 0
			}
		},
		computed: {
			userInfo() {
				return this.$store.state['userinfo']
			}
		},
		onLoad(option) {
			this.name = option.name
			this.$http.get('app/UserController/addUserPost').then(res => {
				if (res.code == 200) {
					this.gwName = res.data.pname
				}
			})
			this.init();
		},
		methods: {
			init() {
				var self = this
				uni.request({
					method: 'GET',
					url: self.$api + '/app/UserController/addUserPost',
					header: {
						'token': uni.getStorageSync('token')
					},
					success: (res) => {
						if (res.data.code == 200) {
							this.textOpen = res.data.data.examination
							this.postId = res.data.data.pid
						}
					}
				})
			},
			studyTest() {
				if (this.postId) {
					uni.reLaunch({
						url: '/pages/examine/schoolTest?postId=' + postId
					})
				} else {
					this.$mHelper.toast('岗位信息错误')
				}
			},
			study() {
				// uni.switchTab({
				// 	url: '../study/study'
				// })
				uni.reLaunch({
					url: '/pages/study/study'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.login-top {
		text-align: center;
		margin: 30rpx 0;

		image {
			width: 249rpx;
			height: 124rpx;

		}
	}

	.greet_img {
		width: 430rpx;
		height: 375rpx;
		margin-bottom: 60rpx;
		margin-top: 60rpx;
	}

	.greet {
		font-size: 40rpx;
		font-weight: bold;
		text-align: center;
	}
</style>
